<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page isELIgnored="false" %>

<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="不可描述">
    <meta name="author" content="wangchengyang">

    <title>客户列表-BootCRM</title>
    <script type="text/css">
        body {
            background: red;
            background-size: 100%;
            background-repeat: no-repeat;
        }
        .setbg{
            background: #3c763d;
        }

    </script>

    <script src="<%=basePath%>/js/jquery-1.11.3.min.js"></script>

    <!-- Bootstrap Core CSS -->
    <link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="<%=basePath%>css/metisMenu.min.css" rel="stylesheet">

    <!-- DataTables CSS -->
    <link href="<%=basePath%>css/dataTables.bootstrap.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="<%=basePath%>css/sb-admin-2.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="<%=basePath%>css/font-awesome.min.css" rel="stylesheet"
          type="text/css">
    <link href="<%=basePath%>css/boot-crm.css" rel="stylesheet"
          type="text/css">

    <script src="<%=basePath%>/js/bootstrap.min.js"></script>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>


</head>

<body>

<canvas id="cas" style="position: absolute;z-index: -2;filter: alpha(opacity:50);opacity: 0.5"></canvas>
<script>

    var canvas = document.getElementById("cas");

    var ctx = canvas.getContext("2d");




    resize();

    window.onresize = resize;




    function resize() {

        canvas.width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;

        canvas.height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;

    }




    var RAF = (function() {

        return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) {

            window.setTimeout(callback, 1000 / 60);

        };

    })();




    // 鼠标活动时，获取鼠标坐标

    var warea = {x: null, y: null, max: 20000};

    window.onmousemove = function(e) {

        e = e || window.event;




        warea.x = e.clientX;

        warea.y = e.clientY;

    };

    window.onmouseout = function(e) {

        warea.x = null;

        warea.y = null;

    };




    // 添加粒子

    // x，y为粒子坐标，xa, ya为粒子xy轴加速度，max为连线的最大距离

    var dots = [];

    for (var i = 0; i < 300; i++) {

        var x = Math.random() * canvas.width;

        var y = Math.random() * canvas.height;

        var xa = Math.random() * 2 - 1;

        var ya = Math.random() * 2 - 1;




        dots.push({

            x: x,

            y: y,

            xa: xa,

            ya: ya,

            max: 6000

        })

    }




    // 延迟100秒开始执行动画，如果立即执行有时位置计算会出错

    setTimeout(function() {

        animate();

    }, 100);




    // 每一帧循环的逻辑

    function animate() {

        ctx.clearRect(0, 0, canvas.width, canvas.height);




        // 将鼠标坐标添加进去，产生一个用于比对距离的点数组

        var ndots = [warea].concat(dots);




        dots.forEach(function(dot) {




            // 粒子位移

            dot.x += dot.xa;

            dot.y += dot.ya;




            // 遇到边界将加速度反向

            dot.xa *= (dot.x > canvas.width || dot.x < 0) ? -1 : 1;

            dot.ya *= (dot.y > canvas.height || dot.y < 0) ? -1 : 1;




            // 绘制点

            ctx.fillRect(dot.x - 0.5, dot.y - 0.5, 1, 1);




            // 循环比对粒子间的距离

            for (var i = 0; i < ndots.length; i++) {

                var d2 = ndots[i];




                if (dot === d2 || d2.x === null || d2.y === null) continue;




                var xc = dot.x - d2.x;

                var yc = dot.y - d2.y;




                // 两个粒子之间的距离

                var dis = xc * xc + yc * yc;




                // 距离比

                var ratio;




                // 如果两个粒子之间的距离小于粒子对象的max值，则在两个粒子间画线

                if (dis < d2.max) {




                    // 如果是鼠标，则让粒子向鼠标的位置移动

                    if (d2 === warea && dis > (d2.max / 2)) {

                        dot.x -= xc * 0.03;

                        dot.y -= yc * 0.03;

                    }




                    // 计算距离比

                    ratio = (d2.max - dis) / d2.max;




                    // 画线

                    ctx.beginPath();

                    ctx.lineWidth = ratio / 2;

                    ctx.strokeStyle = 'rgba(0,0,0,' + (ratio + 0.2) + ')';

                    ctx.moveTo(dot.x, dot.y);

                    ctx.lineTo(d2.x, d2.y);

                    ctx.stroke();

                }

            }




            // 将已经计算过的粒子从数组中删除

            ndots.splice(ndots.indexOf(dot), 1);

        });




        RAF(animate);


    }

</script>
<div id="wrapper">

    <!-- Navigation -->
    <nav class="navbar navbar-default navbar-static-top" role="navigation"
         style="margin-bottom: 0">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse"
                    data-target=".navbar-collapse">
                <span class="sr-only">Toggle navigation</span> <span
                    class="icon-bar"></span> <span class="icon-bar"></span> <span
                    class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="${pageContext.request.contextPath}/customer/list.action">BOOT客户管理系统 v2.1</a>
        </div>
        <!-- /.navbar-header -->

        <ul class="nav navbar-top-links navbar-right">
            <li class="dropdown"><a class="dropdown-toggle"
                                    data-toggle="dropdown" href="#"> <i class="fa fa-envelope fa-fw"></i>
                <i class="fa fa-caret-down"></i>
            </a>
                <ul class="dropdown-menu dropdown-messages">
                                        <li><a href="#">
                                            <div>
                                                <strong>布小新</strong> <span class="pull-right text-muted">
                    									<em>刚刚</em>
                    								</span>
                                            </div>
                                            <div><small style="color:red">上号了</small></div>
                                        </a></li>
                                        <li class="divider"></li>
                                        <li><a class="text-center" href="#"> <strong>查看全部消息</strong>
                                            <i class="fa fa-angle-right"></i>
                                        </a></li>
                                    </ul> <!-- /.dropdown-messages --></li>
                    <!-- /.dropdown -->
            <li class="dropdown"><a class="dropdown-toggle"
                                    data-toggle="dropdown" href="#"> <i class="fa fa-tasks fa-fw"></i>
                <i class="fa fa-caret-down"></i>
            </a>
                <ul class="dropdown-menu dropdown-tasks">
                    <li><a href="#">
                        <div>
                            <p>
                                <strong>任务 1</strong> <span class="pull-right text-muted">完成40%</span>
                            </p>
                            <div class="progress progress-striped active">
                                <div class="progress-bar progress-bar-success"
                                     role="progressbar" aria-valuenow="100" aria-valuemin="0"
                                     aria-valuemax="100" style="width: 40%">
                                    <span class="sr-only">完成100%</span>
                                </div>
                            </div>
                        </div>
                    </a></li>
                    <li class="divider"></li>
                    <li><a href="#">
                        <div>
                            <p>
                                <strong>任务 2</strong> <span class="pull-right text-muted">完成20%</span>
                            </p>
                            <div class="progress progress-striped active">
                                <div class="progress-bar progress-bar-info" role="progressbar"
                                     aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"
                                     style="width: 20%">
                                    <span class="sr-only">完成20%</span>
                                </div>
                            </div>
                        </div>
                    </a></li>
                    <li class="divider"></li>
                    <li><a class="text-center" href="#"> <strong>查看所有任务</strong>
                        <i class="fa fa-angle-right"></i>
                    </a></li>
                </ul> <!-- /.dropdown-tasks --></li>
            <!-- /.dropdown -->
            <li class="dropdown"><a class="dropdown-toggle"
                                    data-toggle="dropdown" href="#"> <i class="fa fa-bell fa-fw"></i>
                <i class="fa fa-caret-down"></i>
            </a>
                <ul class="dropdown-menu dropdown-alerts">
                    <li><a href="#">
                        <div>
                            <i class="fa fa-comment fa-fw"></i> 新回复 <span
                                class="pull-right text-muted small">4分钟之前</span>
                        </div>
                    </a></li>
                    <li class="divider"></li>
                    <li><a href="#">
                        <div>
                            <i class="fa fa-envelope fa-fw"></i> 新消息 <span
                                class="pull-right text-muted small">4分钟之前</span>
                        </div>
                    </a></li>
                    <li class="divider"></li>
                    <li><a href="#">
                        <div>
                            <i class="fa fa-tasks fa-fw"></i> 新任务 <span
                                class="pull-right text-muted small">4分钟之前</span>
                        </div>
                    </a></li>
                    <li class="divider"></li>
                    <li><a href="#">
                        <div>
                            <i class="fa fa-upload fa-fw"></i> 服务器重启 <span
                                class="pull-right text-muted small">4分钟之前</span>
                        </div>
                    </a></li>
                    <li class="divider"></li>
                    <li><a class="text-center" href="#"> <strong>查看所有提醒</strong>
                        <i class="fa fa-angle-right"></i>
                    </a></li>
                </ul> <!-- /.dropdown-alerts --></li>
            <!-- /.dropdown -->
            <li class="dropdown">
                <a class="dropdown-toggle" data-toggle="dropdown" href="#"> <i class="fa fa-user fa-fw"></i>
                <i class="fa fa-caret-down"></i>
                </a>
                <ul class="dropdown-menu dropdown-user">
                    <li><a href="#"><i class="fa fa-user fa-fw"></i> 用户：${USER_SESSION.user_name}</a></li>
                    <li><a href="#"><i class="fa fa-gear fa-fw"></i> 系统设置</a></li>
                    <li class="divider"></li>
                    <li><a href="${pageContext.request.contextPath}/logout.action"><i class="fa fa-sign-out fa-fw"></i>
                        退出登录</a></li>
                </ul> <!-- /.dropdown-user -->
            </li>
            <!-- /.dropdown -->
        </ul>
        <!-- /.navbar-top-links -->

        <div class="navbar-default sidebar" role="navigation">
            <div class="sidebar-nav navbar-collapse">
                <ul class="nav" id="side-menu">
                    <li class="sidebar-search">
                        <div class="input-group custom-search-form">
                            <input type="text" class="form-control" placeholder="查询内容...">
                            <span class="input-group-btn">
								<button class="btn btn-default" type="button">
									<i class="fa fa-search" style="padding: 3px 0 3px 0;"></i>
								</button>
							</span>
                        </div> <!-- /input-group -->
                    </li>
                    <li><a href="customer/list.action" class="active"><i
                            class="fa fa-edit fa-fw"></i> 客户管理</a></li>
                    <li><a href=""><i
                            class="fa fa-dashboard fa-fw"></i> 客户拜访</a></li>
                </ul>
            </div>
            <!-- /.sidebar-collapse -->
        </div>
        <!-- /.navbar-static-side --> </nav>

    <div id="page-wrapper" style="background-image:url(${pageContext.request.contextPath}/images/background.jpg);background-repeat: no-repeat;background-size: 100% ">
        <canvas id="cas" style="position: absolute;z-index: -2;filter: alpha(opacity:50);opacity: 0.5"></canvas>
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">客户管理</h1>
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
        <div class="panel panel-default">
            <div class="panel-body">
                <form class="form-inline" action="${pageContext.request.contextPath }/customer/list.action" method="post">
                    <div class="form-group">
                        <label for="customerName">客户名称</label>
                        <input type="text" class="form-control" id="customerName" value="${custName }" name="custName">
                    </div>
                    <div class="form-group">
                        <label for="customerFrom">客户来源</label>
                        <select	class="form-control" id="customerFrom" placeholder="客户来源" name="custSource">
                            <option value="">--请选择--</option>
                            <c:forEach items="${fromType}" var="item">
                                <option value="${item.dict_id}"<c:if test="${item.dict_id == custSource}"> selected</c:if>>${item.dict_item_name }</option>
                            </c:forEach>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="custIndustry">所属行业</label>
                        <select	class="form-control" id="custIndustry"  name="custIndustry">
                            <option value="">--请选择--</option>
                            <c:forEach items="${industryType}" var="item">
                                <option value="${item.dict_id}"<c:if test="${item.dict_id == custIndustry}"> selected</c:if>>${item.dict_item_name }</option>
                            </c:forEach>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="custLevel">客户级别</label>
                        <select	class="form-control" id="custLevel" name="custLevel">
                            <option value="">--请选择--</option>
                            <c:forEach items="${levelType}" var="item">
                                <option value="${item.dict_id}"<c:if test="${item.dict_id == custLevel}"> selected</c:if>>${item.dict_item_name }</option>
                            </c:forEach>
                        </select>
                    </div>
                    <button type="submit" class="btn btn-primary">查询</button>
                </form>
            </div>
        </div>
        <div class = "row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <button type="button" class="btn btn-default btn-lg" href="#" data-toggle="modal" data-target="#customerCreateDialog" style="background:royalblue"><span class="glyphicon glyphicon-plus"></span>新建</button>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">客户信息列表</div>
                    <!-- /.panel-heading -->
                    <table class="table table-bordered table-striped">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>客户名称</th>
                            <th>客户来源</th>
                            <th>客户所属行业</th>
                            <th>客户级别</th>
                            <th>固定电话</th>
                            <th>手机</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach items="${page.rows}" var="row">
                            <tr>
                                <td>${row.cust_id}</td>
                                <td>${row.cust_name}</td>
                                <td>${row.cust_source}</td>
                                <td>${row.cust_industry}</td>
                                <td>${row.cust_level}</td>
                                <td>${row.cust_phone}</td>
                                <td>${row.cust_mobile}</td>
                                <td>
                                    <a href="#" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#customerEditDialog" onclick="editCustomer(${row.cust_id})">修改</a>
                                    <a href="#" class="btn btn-danger btn-xs" onclick="deleteCustomer(${row.cust_id})">删除</a>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                    <div class="col-md-12 text-right">
                        <common:page url="${pageContext.request.contextPath }/customer/list.action?custName=${custName }&custSource=${custSource }" bean="page" number=""></common:page>
                    </div>
                    <!-- /.panel-body -->
                </div>
                <!-- /.panel -->
            </div>
            <!-- /.col-lg-12 -->
        </div>
    </div>
    <!-- /#page-wrapper -->

</div>
<!-- 客户编辑对话框 -->
<div class="modal fade" id="customerEditDialog" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">修改客户信息</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" id="edit_customer_form">
                    <input type="hidden" id="edit_cust_id" name="cust_id"/>
                    <div class="form-group">
                        <label for="edit_customerName" class="col-sm-2 control-label">客户名称</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="edit_customerName" placeholder="客户名称" name="cust_name">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="edit_customerFrom" style="float:left;padding:7px 15px 0 27px;">客户来源</label>
                        <div class="col-sm-10">
                            <select	class="form-control" id="edit_customerFrom" placeholder="客户来源" name="cust_source">
                                <option value="">--请选择--</option>
                                <c:forEach items="${fromType}" var="item">
                                    <option value="${item.dict_id}"<c:if test="${item.dict_id == custSource}"> selected</c:if>>${item.dict_item_name }</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="edit_custIndustry" style="float:left;padding:7px 15px 0 27px;">所属行业</label>
                        <div class="col-sm-10">
                            <select	class="form-control" id="edit_custIndustry"  name="cust_industry">
                                <option value="">--请选择--</option>
                                <c:forEach items="${industryType}" var="item">
                                    <option value="${item.dict_id}"<c:if test="${item.dict_id == custIndustry}"> selected</c:if>>${item.dict_item_name }</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="edit_custLevel" style="float:left;padding:7px 15px 0 27px;">客户级别</label>
                        <div class="col-sm-10">
                            <select	class="form-control" id="edit_custLevel" name="cust_level">
                                <option value="">--请选择--</option>
                                <c:forEach items="${levelType}" var="item">
                                    <option value="${item.dict_id}"<c:if test="${item.dict_id == custLevel}"> selected</c:if>>${item.dict_item_name }</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="edit_linkMan" class="col-sm-2 control-label">联系人</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="edit_linkMan" placeholder="联系人" name="cust_linkman">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="edit_phone" class="col-sm-2 control-label">固定电话</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="edit_phone" placeholder="固定电话" name="cust_phone">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="edit_mobile" class="col-sm-2 control-label">移动电话</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="edit_mobile" placeholder="移动电话" name="cust_mobile">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="edit_zipcode" class="col-sm-2 control-label">邮政编码</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="edit_zipcode" placeholder="邮政编码" name="cust_zipcode">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="edit_address" class="col-sm-2 control-label">联系地址</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="edit_address" placeholder="联系地址" name="cust_address">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="updateCustomer()">保存修改</button>
            </div>
        </div>
    </div>
</div>
<!-- /#wrapper -->


<div class="modal fade" id="customerCreateDialog" tabindex="-1" role="dialog"
     aria-labelledby="myCreateLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myCreateLabel">创建</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" id="create_customer_form">
                    <input type="hidden" id="create_cust_id" name="cust_id"/>
                    <div class="form-group">
                        <label for="edit_customerName" class="col-sm-2 control-label">客户名称</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="create_customerName" placeholder="客户名称" name="cust_name">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="edit_customerFrom" style="float:left;padding:7px 15px 0 27px;">客户来源</label>
                        <div class="col-sm-10">
                            <select	class="form-control" id="create_customerFrom" placeholder="客户来源" name="cust_source">
                                <option value="">--请选择--</option>
                                <c:forEach items="${fromType}" var="item">
                                    <option value="${item.dict_id}"<c:if test="${item.dict_id == custSource}"> selected</c:if>>${item.dict_item_name }</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="edit_custIndustry" style="float:left;padding:7px 15px 0 27px;">所属行业</label>
                        <div class="col-sm-10">
                            <select	class="form-control" id="create_custIndustry"  name="cust_industry">
                                <option value="">--请选择--</option>
                                <c:forEach items="${industryType}" var="item">
                                    <option value="${item.dict_id}"<c:if test="${item.dict_id == custIndustry}"> selected</c:if>>${item.dict_item_name }</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="edit_custLevel" style="float:left;padding:7px 15px 0 27px;">客户级别</label>
                        <div class="col-sm-10">
                            <select	class="form-control" id="create_custLevel" name="cust_level">
                                <option value="">--请选择--</option>
                                <c:forEach items="${levelType}" var="item">
                                    <option value="${item.dict_id}"<c:if test="${item.dict_id == custLevel}"> selected</c:if>>${item.dict_item_name }</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="edit_linkMan" class="col-sm-2 control-label">联系人</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="create_linkMan" placeholder="联系人" name="cust_linkman">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="edit_phone" class="col-sm-2 control-label">固定电话</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="create_phone" placeholder="固定电话" name="cust_phone">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="edit_mobile" class="col-sm-2 control-label">移动电话</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="create_mobile" placeholder="移动电话" name="cust_mobile">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="edit_zipcode" class="col-sm-2 control-label">邮政编码</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="create_zipcode" placeholder="邮政编码" name="cust_zipcode">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="edit_address" class="col-sm-2 control-label">联系地址</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="create_address" placeholder="联系地址" name="cust_address">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="createCustomer()">新建</button>
            </div>
        </div>
    </div>
</div>






<!-- jQuery -->
<%--<script src="<%=basePath%>js/jquery.min.js"></script>--%>

<!-- Bootstrap Core JavaScript -->
<%--    <script src="<%=basePath%>js/bootstrap.min.js"></script>--%>

<!-- Metis Menu Plugin JavaScript -->
<script src="<%=basePath%>js/metisMenu.min.js"></script>

<!-- DataTables JavaScript -->
<script src="<%=basePath%>js/jquery.dataTables.min.js"></script>
<script src="<%=basePath%>js/dataTables.bootstrap.min.js"></script>

<!-- Custom Theme JavaScript -->
<script src="<%=basePath%>js/sb-admin-2.js"></script>

<script type="text/javascript">
        function editCustomer(id) {
            $.ajax({
                type:"get",
                url:"<%=basePath%>customer/edit.action",
                data:{"id":id},
                success:function(data) {
                    data = eval("("+data+")")
                    console.log(data);
                    console.log(data.cust_id)

                    $("#edit_cust_id").val(data.cust_id);
                    $("#edit_customerName").val(data.cust_name);
                    $("#edit_customerFrom").val(data.cust_source)
                    $("#edit_custIndustry").val(data.cust_industry)
                    $("#edit_custLevel").val(data.cust_level)
                    $("#edit_linkMan").val(data.cust_linkman);
                    $("#edit_phone").val(data.cust_phone);
                    $("#edit_mobile").val(data.cust_mobile);
                    $("#edit_zipcode").val(data.cust_zipcode);
                    $("#edit_address").val(data.cust_address);

                }
            });
        }
    function updateCustomer() {
        $.post("<%=basePath%>customer/update.action",$("#edit_customer_form").serialize(),function(data){
            alert("客户信息更新成功！");
            window.location.reload();
        });
    }

    function deleteCustomer(id) {
        if(confirm('确实要删除该客户吗?')) {
            $.post("<%=basePath%>customer/delete.action",{"id":id},function(data){
                alert("客户删除更新成功！");
                window.location.reload();
            });
        }
    }

    function createCustomer(){

        if($("#edit_customerName").val() === null){
                alert("客户名称不能为空" +  $("#create_customerName").val())
        }
        else if($("#edit_customerName").val() === null){
            alert("客户来源不能为空")
        }
        else if($("#edit_customerName").val() === null){
            alert("客户行业不能为空")
        }
        else if($("#edit_customerName").val() === null){
            alert("客户等级不能为空")
        }else{

            $.post("<%=basePath%>customer/create.action",$("#create_customer_form").serialize(),function(data){
                alert("客户创建成功！");
                window.location.reload();
            });
        }



    }



</script>

</body>

</html>
